define(['jquery', 'bootstrap', 'backend', 'table', 'form','vue'], function ($, undefined, Backend, Table, Form,Vue) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'log/withdraw_log/index'
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                search:false,
                columns: [
                    [
                        {field: 'state', checkbox: true },
                        {field: 'id', title: 'ID',sortable:true},
                        {field: 'money', title: __('Money'),searchable:false},
                        {field: 'poundage', title: __('Poundage'),searchable:false},
                        {field: 'user_nickname', title: __('User nickname'),searchable:false},
                        {field: 'user_id', title: __('User ID')},
                        {field: 'status', title: __('Status'),formatter:function(value,row,index){
                            value = '' + value;
                            switch (value){
                                case '0':
                                    return __('Wait');
                                case '1':
                                    return __('Verify passed');
                                case '2':
                                    return __('Verify fail');
                                default:
                                    return __('Wait');
                            }
                        },searchList: {'0': __('Wait'), '1': __('Verify passed'),'2':__('Verify fail')}, style: 'min-width:100px;'
                        },
                        {field: 'desc', title: __('Verify desc'),searchable:false},
                        {field: 'create_time', title: __('Create time'),
                            formatter: Table.api.formatter.datetime, operate: 'BETWEEN',
                            type: 'datetime', addclass: 'datetimepicker',
                            data: 'data-date-format="YYYY-MM-DD"'
                        },
                        {field: 'operate', title: __('Verify'), table: table, events: Table.api.events.operate,
                            buttons: [{
                                name: 'verify',
                                text: __('Verify'),
                                icon: 'fa fa-check',
                                classname: 'btn btn-info btn-xs btn-detail btn-dialog',
                                url: 'log/withdraw_log/verify'
                            }],
                            formatter: function (value, row, index) {
                                if(row.status == '1'){
                                    return '<a href="#" class="btn btn-info btn-xs btn-success" title="审核通过"><i class="fa fa-check"></i>通过</a>';
                                }else if(row.status == '2'){
                                    return '<a href="#" class="btn btn-info btn-xs btn-warning" title="审核不通过"><i class="fa fa fa-close"></i>不通过</a>';
                                }
                                return Table.api.formatter.operate.call(this, value, row, index);
                            }
                        }
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        verify: function () {
            Form.api.bindevent($("form[role=form]"));
        }
    };
    return Controller;
});